package com.oa.dao.impl;

import java.io.Serializable;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import com.oa.dao.DeptDao;
import com.oa.entity.Dept;

public class DeptDaoImpl implements DeptDao {

	private SessionFactory sessionFactory;
	private Session session;

	@Override
	public Integer saveDept(Dept dept) {
		session = getSessionFactory().getCurrentSession();
		Serializable id = session.save(dept);
		return (Integer) id;
	}
	

	@Override
	public int deleteDept(int deptno) {
		session = getSessionFactory().getCurrentSession();
		session.delete(session.get(Dept.class, deptno));
		return 1;
	}
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	

}
